<?php


namespace app\api\controller;


use app\common\controller\Api;
use think\Db;

class Msg extends Api
{
    protected $noNeedLogin = ['test'];
    // 无需鉴权的接口,*表示全部
    protected $noNeedRight = ['*'];

    public function notice()
    {
        $userid = $this->auth->id;
        $kefuid = Db::name('kefu_user')->where(['user_id'=>$userid])->value('id');
        $sessionid = Db::name('kefu_session')->where(['user_id'=>$kefuid,'deletetime'=>null])->value('id');
        $map = [
            'session_id' => $sessionid,
            'status' => 0,
        ];
        $row = Db::name('kefu_record')->where($map)->find();
        $data = [
            'is_read' => $row?1:0, // =1 有未读消息 =0 无未读消息
        ];
        $this->success('成功',$data);
    }
}
